﻿using System;
using System.Web;
using System.Web.Caching;
using System.Web.UI;
using H2.NET.Business;
using H2.NET.Data.Common;

namespace H2.NET.Web.Pages.SMD.Service
{
    /// <summary>
    /// 数据访问类:t_cache
    /// </summary>
    public static class CacheService
    {
        public static string GetCache(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return string.Empty;
            }
            if (HttpContext.Current.Cache[key.Trim()] == null)
            {
                var caches = (t_Cache.id > 0).List<t_Cache>(Storage.Context1);
                foreach (var cache in caches)
                {
                    HttpContext.Current.Cache.Insert(cache.CacheKey, cache.CacheValue);
                }
            }

            return HttpContext.Current.Cache[key.Trim()] == null ? key : HttpContext.Current.Cache[key.Trim()].ToString();
        }

    }
}

